﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace myomscl_web.Admin
{
    public partial class Myomscl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.menuScreen.LoadTree("root", null);
                this.menuUser.LoadTree("root", null);
            }
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            this.menuUser.TreeClick += new UserControls.OnTreeClick(menuUser_TreeClick);
            this.menuScreen.TreeClick += new UserControls.OnTreeClick(menuScreen_TreeClick);
            this.userTypeForm.ModifyingUserType += new UserControls.ucUserType.OnModifyingUserType(userTypeForm_ModifyingUserType);
            this.lbListColumns.Click += new EventHandler(lbListColumns_Click);
        }

        void menuUser_TreeClick(string type, string id)
        {
            if (string.IsNullOrEmpty(type)||type=="root")
            {
                userTypeForm.UserTypeId = null;
                userTypeForm.LoadUserType();                
            }
            else
            {
                if (type == "ut")
                {
                    userTypeForm.UserTypeId = id;
                    userTypeForm.LoadUserType();                    
                }
                else if (type == "org")
                {
                }
                else if (type == "us")
                {
                }
            }

        }

        void menuScreen_TreeClick(string type, string id)
        {
            if (type == "root")
            {
                listScreenForm.IsNewListScreen = true;
                listScreenForm.LoadScreen();
                listScreenForm.Visible = true;
                menuScreen.LoadTree("root", null);
            }
            else
            {
                if (type == "ls")
                {
                    listScreenForm.IsNewListScreen = false;
                    listScreenForm.SelectedListScreenId = id;
                    listScreenForm.LoadScreen();
                    listScreenForm.Visible = true;
                    menuScreen.LoadTree("ls", id);
                }
            }
        }

        void userTypeForm_ModifyingUserType(string newTypeName)
        {
            this.menuUser.LoadTree("ut", newTypeName);
            this.userTypeForm.Visible = false;
        }

        protected void lbListColumns_Click(object sender, EventArgs e)
        {
            listColumnForm.Visible = true;
            listColumnForm.LoadColumns();
        }
    }
}